<template>
	<div>
		<el-row :gutter="40">
			<el-col :span="8" :offset="8">
				<el-date-picker
					v-model="monthValue" type="month" size="mini" @change="changeMonth"
				></el-date-picker>
			</el-col>
		</el-row>
		<el-calendar v-model="monthValue" class="zll_calendar">
			<template slot="dateCell" slot-scope="{ date, data }">
				<p :class="data.isSelected ? 'is-selected' : ''">
					{{ data.day.split("-").slice(1).join("-") }}
					{{ data.isSelected ? "✔️" : "" }}
				</p>
			</template>
		</el-calendar>
	</div>
</template>

<script>
	import {formatDate} from "@/plugins/formatDate";
	export default {
		data() {
			return {
				monthValue: '',
			}
		},
		methods: {
			changeMonth() {
				this.monthValue = new Date(this.monthValue);
			},
			submitForm(val, type) {
				let self = this;
				if(!this.monthValue){
					self.$message.warning('请选择一个日期');
					return;
				}
				let chooseDay = formatDate(new Date(this.monthValue), 'yyyy-MM-dd');
				if(new Date(chooseDay+" 23:59:59").getTime() < new Date().getTime()){
					self.$message.warning('请选择今天或者以后的日期');
					return;
				}

				self.$http({
					url: "/jinl/ondutyweek/addOnDutyWeek",
					method: "post",
					params:{dutyDay:chooseDay}
				}).then(resp => {
					if (resp.success) {
						self.$message.success('添加日期成功');
						self.$eventBus.$emit("updatePlanIssue");
					}else{
						self.$message.error(resp.message);
					}
				});
			},
		}
	};
</script>

<style>
</style>